package com.example.senior_config.controller;

import org.apache.commons.io.FileUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @author ljw
 * @description
 * @date 2021/9/8 7:15
 */
@RestController
public class UploadController {


    @RequestMapping(value = "/upload", method = RequestMethod.POST)
    public String upload(MultipartFile file) {
        try {
            FileUtils.writeByteArrayToFile(new File("G:/upload/"+file.getOriginalFilename()), file.getBytes());
        } catch (IOException e) {
            e.printStackTrace();
            return "wrong";
        }
        return "ok";
    }
}
